package main

import "fmt"

func main()  {
	a := 3
	b := 2
	fmt.Println(a, b)
	// 方法1. 直接交换
	a, b = b, a
	fmt.Println(a, b)
	//方法2.借助第三个变量
	a = 3
	b = 2
	temp := a
	a = b
	b = temp
	fmt.Println(a, b)

	// 方法3.
	a = 3
	b = 2
	a = a + b // a=5,b=2
	b = a - b // a=5,b=3
	a = a - b // a=2,b=3
	fmt.Println(a, b)
	//方法4，
	a = 3
	b = 2
	a = a ^ b
	b = a ^ b
	a = a ^ b
	fmt.Println(a, b)

}
